package com.xuelang.pipeline.worker.app.log.config;

import com.xuelang.pipeline.worker.app.log.LogProviderWebSocketHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * <p>日志提供方WebSocket配置</p>
 *
 * @author : yixin.lys
 * @date : 2024-07-01 11:02
 **/
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(logProviderWebSocketHandler(), "/log-provider-server-url");
    }

    @Bean
    public LogProviderWebSocketHandler logProviderWebSocketHandler(){
        return new LogProviderWebSocketHandler();
    }
}
